package com.resource.project.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.resource.project.entity.RespBean;
import com.resource.project.entity.TResourcePlan;
import com.resource.project.mapper.TResourcePlanMapper;
import com.resource.project.service.ITResourcePlanService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.resource.project.service.ITResourceService;
import com.resource.util.page.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 领料计划表 服务实现类
 * </p>
 *
 * @author resource
 * @since 2020-12-08
 */
@Service
public class TResourcePlanServiceImpl extends ServiceImpl<TResourcePlanMapper, TResourcePlan> implements ITResourcePlanService {
    @Autowired
    private ITResourceService resourceService;
    @Override
    public IPage<TResourcePlan> page(PageParam pageParam, TResourcePlan resource) {
        return page(pageParam.toMybaitsPage(),Wrappers.<TResourcePlan>lambdaQuery().eq(resource.getType()!=null,TResourcePlan::getType,resource.getType()))
                .convert(tResourceManage ->tResourceManage.setResourceName(resourceService.getById(tResourceManage.getResourceId()).getName()));
    }

    @Override
    public RespBean add(TResourcePlan resource) {
        return RespBean.ok(save(resource));
    }

    @Override
    public RespBean updateTResourcePlan(TResourcePlan resource) {
        return null;
    }
}
